<template>
  <n-modal
    v-model:show="getProps.modalData.show"
    class="custom-card"
    preset="card"
    :style="{ width: '500px' }"
    :bordered="false"
    :segmented="{
      content: true,
      footer: true
    }"
    :closable="false"
    :mask-closable="false"
  >
    <n-space style="margin-bottom: 10px" justify="start"> 广告正在上传中，请前往【上传管理】中进行查看。 </n-space>
    <n-space justify="end" align="end">
      <x-button @click="handleSave">前往上传管理</x-button>
      <x-button type="primary" @click="handleCancel">确定</x-button>
    </n-space>
  </n-modal>
</template>

<script setup lang="ts">
  import { reactive, ref } from 'vue'
  import { XButton } from '@/components'
  import { NModal, NSpace } from 'naive-ui'
  import { useStore } from '@/store'
  import { useRoute, useRouter } from 'vue-router'
  const route = useRoute()
  const router = useRouter()
  const emits = defineEmits(['success'])

  const store = useStore()
  const props = defineProps({
    modalData: {
      type: Object,
      default: () => ({})
    }
  })
  const getProps = reactive(props)
  const form = ref({
    type: 0,
    range: []
  })
  const typeList = reactive([
    {
      label: '全天',
      value: 0
    },
    {
      label: '指定时间段',
      value: 1
    }
  ])
  async function handleSave() {
    await store.dispatch('permission/setClearCache', true)
    router.push({
      name: 'UploadManage',
      query: {
        accountCode: route.query.accountCode
      }
    })
  }
  function handleCancel() {
    getProps.modalData.show = false
    emits('success')
  }
</script>

<style scoped lang="scss">
  .tips {
    margin-top: 20px;
  }
  .max-cost {
    padding: 10px 0;
    text-align: center;
  }
</style>
